<template>
  <div class="search">
    <f-form ref="form" :action="api.supplier" :form-key="this.formItem.supplierId">
      <f-form-item label="供应商名称" name="supplierName" :required="true" :value="formItem.supplierName"/>
      <f-form-item label="公司垫付方式" type="select" name="supplierBondType" :required="true" dataType="number" :data="api.supplier.supplierBondType" :value.sync="formItem.supplierBondType"/>
      <f-form-item label="纳税识别号" name="taxNumber"  :value="formItem.taxNumber"/>
      <f-form-item label="联系人" name="linkMan"  :value="formItem.linkMan"/>
      <f-form-item label="联系电话" name="linkTel" :value="formItem.linkTel"/>
      <f-form-item label="地址" name="address" :value="formItem.address"/>
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'

  export default {
    name: 'supplierForm',
    props: {},
    data() {
      return {
        refs: this.$refs,
        api: Object.assign(api, this.api),
        companyAutoLoad:false,
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          supplierId: '',
          supplierName: '',
          companyId: '',
          supplierBondType:null,
          organizationId: '',
          taxNumber: '',
          linkMan: '',
          linkTel: '',
          address: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.supplierId) {
          let params = {
            supplierId: data.supplierId
          }
          this.refs['form'].getDetails(params, (data) => {
            this.formItem = data
            this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({}, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
